<?php
// 定单控制器
class OrderAction extends BaseAction {

 	public function index()
 	{
   		$begin_date = $_REQUEST['begin_date'];
   		$end_date = $_REQUEST['end_date'];
   		if( isset($_REQUEST['person_num'] ) )
	   		$person_num = (int) $_REQUEST['person_num'];

     	$this->assign('begin_date',$begin_date);
     	$this->assign('end_date',$end_date);
     	$this->assign('person_num',  $person_num );

     	$this->display();
 	}

 	public function save()
 	{

        header("Content-Type:text/html; charset=utf-8");
		$model = D ('Order');

		$_POST['date'] = date('Y-m-d',time());

		if (false === $model->create ()) {
			$this->error ( $model->getError () );
		}

		//保存当前数据对象
		$list=$model->add ();
		if ($list!==false) { //保存成功
			$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) );
   			echo '<script language="javascript">alert("定单提交成功！");location.href="/";</script>';	//返回
   			exit;
		} else {
			//失败提示
			echo '<script language="javascript">alert("定单提交失败!");history.back();</script>';	//返回
			exit;
		}

 	}

}